﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WfhTrader.Core.Trading
{
    /// <summary>
    /// 证券基类
    /// </summary>
    public abstract class Security
    {
        /// <summary>
        /// 市场
        /// </summary>
        public MarketType Market { get; set; }

        /// <summary>
        /// 代码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 交易单位（每手数量）
        /// </summary>
        public int TradeUnit { get; set; }

        /// <summary>
        /// 最小变动价位
        /// </summary>
        public double PriceTick { get; set; }

        /// <summary>
        /// 当前是否交易
        /// </summary>
        public bool IsTrading { get; set; }

        /// <summary>
        /// 比较两个实例是否相等
        /// </summary>
        /// <param name="obj">实例</param>
        /// <returns>市场和代码相同返回True，否则返回False</returns>
        public override bool Equals(object obj)
        {
            if (obj == null) return false;

            Security target = obj as Security;

            return (this.Market == target.Market && this.Code == target.Code);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
